package smedi.ismedi.web.bff.controller.report;

import com.smedi.ismedi.report.api.feign.RemoteReportDocCenterFeignApi;
import com.smedi.ismedi.report.api.model.dto.DocumentCenterDto;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = {"资料管理-资料中心"})
@RequestMapping(value = "/webbff/v1/center")
@RestController
public class RemoteReportDocCenterController {

    @Autowired
    RemoteReportDocCenterFeignApi remoteReportDocCenterFeignApi;

    /**
     * 列表
     * @return
     */
    @ApiOperation(value = "查询报表记录", nickname = "查询报表记录")
    @PostMapping("/list")
    public ResponseData<PaginationData<DocumentCenterDto>> getList(@RequestBody DocumentCenterDto documentCenterDto){
        return remoteReportDocCenterFeignApi.getList(documentCenterDto);
    }

    /**
     * 左侧目录树
     * @return
     */
    @ApiOperation(value = "左侧目录树", nickname = "左侧目录树")
    @GetMapping("/leftree")
    public ResponseData<List<Map<String, Object>>> leftCatalog(){
        return remoteReportDocCenterFeignApi.leftCatalog();
    }

    /**
     * 下载Zip包
     */
    @ApiOperation(value = "下载Zip包", nickname = "下载Zip包")
    @GetMapping("/zip/{taskIds}")
    public ResponseEntity<byte[]> downloadZip(@PathVariable("taskIds") Long[] taskIds){
        return remoteReportDocCenterFeignApi.downloadZip(taskIds);
    }
}
